﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace JsonFormat
{
    class NV
    {
        public string Name { get; set; }
        public string Value { get; set; }

        public string str()
        {
            StringBuilder sb = new StringBuilder();
            return sb.Append(Name).Append(":").Append(Value).ToString();
        }
    }

    class Utils
    {

        public static List<NV> GetProNVLst(Object obj)
        {
            List<NV> kvs = new List<NV>(); 
            foreach (PropertyInfo p in obj.GetType().GetProperties())
            {
                NV kv = new NV();
                kv.Name = p.Name;
                if(p.GetValue(obj) != null)
                {
                    kv.Value = p.GetValue(obj).ToString();
                }
                kvs.Add(kv);
            }
            return kvs;
        }

    }
}
